// DirectDrawWrapperUnmanaged.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "DDrawUnmanaged.h"
DDBLTFX bltFX = DDBLTFX();

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	bltFX.dwSize = sizeof(DDBLTFX);
    return TRUE;
}

HRESULT LoopIt(DWORD x)
{
	//byte* a = (byte*)malloc(x);
//	int y = 0;
	//for(DWORD i = 0; i < x; ++i)

	DWORD i = 0;
	int y = 0;

	do
	{
		y = 0x00;
	}
	while(i++ < x);

	//free(a);

	return 0;
}

HRESULT Blt(void* destSurface, LPRECT dest, void* sourceSurface, 
		LPRECT src, DWORD flags, LPDDBLTFX fx)
{
	return ((IDirectDrawSurface*)destSurface)->Blt(dest,(IDirectDrawSurface*)sourceSurface,src,flags,fx);
};
HRESULT Flip(void* surface, DWORD flags)
{
	return ((IDirectDrawSurface*)surface)->Flip(NULL,flags);
};

HRESULT Fill(void* surface,DWORD color)
{
	bltFX.dwFillColor = color; // no thread safe.
	return ((IDirectDrawSurface*)surface)->Blt(NULL,NULL,NULL,DDBLT_COLORFILL, &bltFX);
}

